<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;指标数据
  </div>
  <div class="clwork">
    <div class="top">
    <!-- first-input -->
				<input nz-input placeholder="所属指标名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['indexname:like']" />
      <nz-button-group class="fm-search-input">
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <div class="left top-left">
      <nz-tree nzAsyncData
        (nzClick)="fs.loadDataEx($event.node.key)"
        [nzData]="sideDic.treeDatas">
      </nz-tree>
    </div>

    <div class="right top-right">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger
        [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
        [nzFrontPagination]="false"
        [nzData]="fs.datas"
        [nzLoading]="fs.isLoading || fs.isDeleing"
        [nzTotal]="fs.rowsCount"
        [(nzPageIndex)]="fs.pageIndex"
        [(nzPageSize)]="fs.pageSize"
        (nzPageIndexChange)="fs.loadData()"
        (nzPageSizeChange)="fs.loadData(true)">
        <thead>
            <tr>
                <th nzShowCheckbox [(nzChecked)]="fs.allChecked"
                    [nzIndeterminate]="fs.indeterminate"
                    (nzCheckedChange)="fs.checkAll($event)"></th>
                <th nzWidth="20%">指标名称</th>
                <th nzWidth="20%">政区名称</th>
                <th nzWidth="20%">年份</th>
                <th nzWidth="20%">月份</th>
                <th nzWidth="20%">数据值</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let data of fs.datas">
                <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
                </td>
                <!-- <td><span (click)="fs.editRow(data)" class="form-edit"></span></td> -->
                <td><span (click)="editReport(data)" class="form-edit">{{data.indexname}}</span></td>
            		<td>{{data.adminname}}</td>
                <td>{{data.year}}</td>
            		<td>{{data.month}}</td>
            		<td>{{data.value}}</td>
            </tr>
        </tbody>
    </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false'
        [nzFooter]="null"
        [(nzVisible)]="fs.isEditVisible"
        (nzOnCancel)="fs.closeEdit()" >
        <form nz-form [nzLayout]="'inline'">
          <input nz-input [(ngModel)]="fs.er.id" type="hidden"
                 name="id" required #id="ngModel" />
          <input nz-input [(ngModel)]="fs.er.indexid" type="hidden"
                 name="indexid" required #indexid="ngModel" />
          <input nz-input [(ngModel)]="fs.er.adminid" type="hidden"
                 name="adminid" required #adminid="ngModel" />
			    <div nz-row [nzGutter]="24">
                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">名称</nz-form-label>
                    <nz-form-control class="form-control" [nzValidateStatus]="indexname.invalid?'error':'success'" nzHasFeedback>
                      <input nz-input [(ngModel)]="fs.er.indexname"
                             name="indexname" required #indexname="ngModel" />
                    </nz-form-control>
                  </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                  <nz-form-item>
                    <nz-form-label nzRequired class="form-label">数据值</nz-form-label>
                    <nz-form-control class="form-control" [nzValidateStatus]="value.invalid?'error':'success'" nzHasFeedback>
                      <nz-input-number [(ngModel)]="fs.er.value"
                                       name="value" required #value="ngModel" class="form-control">
                      </nz-input-number>
                    </nz-form-control>
                  </nz-form-item>
                </div>
          </div>

          <div nz-row [nzGutter]="24">
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">政区</nz-form-label>
                <nz-form-control class="form-control" [nzValidateStatus]="adminid.invalid?'error':'success'" nzHasFeedback>
                  <nz-tree-select required class="form-control" nzPlaceHolder="请选择" [nzDropdownMatchSelectWidth]="true"
                      [nzDropdownStyle]="{ 'max-height': '300px' }" [(ngModel)]="fs.er.adminid" name="adminid"  #adminid="ngModel"
                      [nzAsyncData]="true" [nzNodes]="administrativeDic.treeDatas">
                  </nz-tree-select>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">排序值</nz-form-label>
                <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'" nzHasFeedback>
                  <nz-input-number [(ngModel)]="fs.er.order"
                    name="order" required #order="ngModel"
                    [nzMin]="1" [nzMax]="100" [nzStep]="1" class="form-control">
                  </nz-input-number>
                </nz-form-control>
              </nz-form-item>
            </div>
          </div>

          <div nz-row [nzGutter]="24">
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">年份</nz-form-label>
                <nz-form-control class="form-control" [nzValidateStatus]="reportYear.invalid?'error':'success'" nzHasFeedback>
                  <nz-year-picker [(ngModel)]="fs.er.reportYear" class="form-control"
                  name="reportYear" required #reportYear="ngModel"  nzPlaceHolder="年份"></nz-year-picker>
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">月份</nz-form-label>
                <nz-form-control class="form-control" [nzValidateStatus]="month.invalid?'error':'success'" nzHasFeedback>
                  <nz-select [(ngModel)]="fs.er.month" name="month" required required class="form-control"
                    #month="ngModel" (nzOpenChange)="monthDic.load('0')" [nzPlaceHolder]="'请选择'">
                    <nz-option *ngFor="let option of monthDic.datas" [nzLabel]="option.display" [nzValue]="option.code">
                    </nz-option>
                    <nz-option *ngIf="monthDic.isLoading" nzDisabled nzCustomContent>
                      <i nz-icon type="loading"></i>加载中...
                    </nz-option>
                    <span *ngIf="!monthDic.isLoaded">
                      <nz-option [nzLabel]="fs.er.monthName" [nzValue]="fs.er.month">
                      </nz-option>
                    </span>
                  </nz-select>
                </nz-form-control>
              </nz-form-item>
            </div>
          </div>

		    	<div nz-row [nzGutter]="24">
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">单位</nz-form-label>
                <nz-form-control class="form-control" [nzValidateStatus]="unit.invalid?'error':'success'" nzHasFeedback>
                  <input nz-input [(ngModel)]="fs.er.unit"
                          name="unit" required #unit="ngModel" />
                </nz-form-control>
              </nz-form-item>
            </div>
            <div nz-col [nzSpan]="12">
              <nz-form-item>
                <nz-form-label nzRequired class="form-label">有效</nz-form-label>
                <nz-form-control class="form-control">
                  <nz-switch nzCheckedChildren="有" nzUnCheckedChildren="无" [(ngModel)]="fs.er.valid" name="valid">
                  </nz-switch>
                </nz-form-control>
              </nz-form-item>
            </div>
          </div>

          <div nz-row [nzGutter]="24">
            <div nz-col [nzSpan]="24" class="form-button-align">
              <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
              <button nz-button nzType="primary"
                [disabled]='id.invalid || indexname.invalid || value.invalid || reportYear.invalid || month.invalid || order.invalid || unit.invalid'
                (click)="saveForm()" [nzLoading]="fs.isSaveing">保存</button>
            </div>
          </div>
        </form>
    </nz-modal>
  </div>
</div>
